(defun sir (n)
  (if (evenp n) (/ n 2) (1+ (* 3 n))))

(defun sir-length (n)
  (do* ((i 0 (1+ i))
       (s n (sir s)))
      ((= s 1) (1+ i))))

(print 
 (let ((max 0) (maxsize 0))
      (do ((i 1000000 (1- i)))
	   ((zerop i) max)
	(let ((size (sir-length i)))
	  (if (< maxsize size) (setq max i maxsize size))))))

